/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.gob.foncodes.ssa.web.controller;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;
import org.apache.log4j.Logger;
import pe.gob.foncodes.ssa.bs.administracion.controller.GenericMaintenanceController;
import pe.gob.foncodes.ssa.bs.seguridad.domain.Zonal;

/**
 *
 * @author Planvital
 */
public class ZonalController extends GenericMaintenanceController implements ValueChangeListener {

    private static Logger log = Logger.getLogger(ZonalController.class);
    private List<Zonal> lstZonal;
    private Zonal zonalFiltro;

    @Override
    @PostConstruct
    public void init() throws Exception {
        FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        lstZonal = new ArrayList<Zonal>();
        lstZonal = getService().findByNamedQuery("Zonal.findAll");
        log.info("Cargo Combo Zonal");
        setBeanList(getLstZonal());
    }

    public void filtrarUnidadOrganizacional(ValueChangeEvent event) {
        log.info("entra... al value change event");
        //Object objNew = event.getNewValue();


        //log.info("aa "+objNew.toString());

    }

    public void filtrarUnidadOrganizacional() {
        log.info("entra... sin evento");
        //Object objNew = event.getNewValue();


        //log.info("aa "+objNew.toString());
        log.info("Invocar con codzonal" + zonalFiltro.getCodZonal());
    }

    /**
     * @return the lstZonal
     */
    public List<Zonal> getLstZonal() {
        return lstZonal;
    }

    /**
     * @param lstZonal the lstZonal to set
     */
    public void setLstZonal(List<Zonal> lstZonal) {
        this.lstZonal = lstZonal;
    }

    /**
     * @return the zonalFiltro
     */
    public Zonal getZonalFiltro() {
        return zonalFiltro;
    }

    /**
     * @param zonalFiltro the zonalFiltro to set
     */
    public void setZonalFiltro(Zonal zonalFiltro) {
        this.zonalFiltro = zonalFiltro;
    }

    public void valueChanged(ValueChangeEvent vce) {
        System.out.println("listner");
    }

    public void processValueChange(final ValueChangeEvent ce) throws AbortProcessingException {
        System.out.println("listner");
    }
}
